import request from '@/utils/request.ts'

const PREFIX = '/post'
const POST_URL = '/'
const HOT_POST_URL = '/hot/'
const New_POST_URL = '/like/'


export const GetPostById = async (id: any) => {
    return await request.get(PREFIX + POST_URL + id)
}
export const getPosts = async (start: any, end: any) => {
    return await request.get(PREFIX + POST_URL, {params: {start, end}})
}
export const getHotPosts = async () => {
    return await request.get(PREFIX + HOT_POST_URL)
}
export const getNewPosts = async () => {
    return await request.get(PREFIX + New_POST_URL)
}
export const updatePost = async (id: any, data: any) => {
    return await request.put(PREFIX + POST_URL + id, data)
}
export const deletePostSync = async (id: any) => {
    return await request.delete(PREFIX + POST_URL + id)
}
export const addPostSync = async (data: any) => {
    return await request.post(PREFIX + POST_URL, data)
}